home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / mac / developm / language / harvest.cpt / Harvest C / Tcl 6.2 / tcl.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-04-13  |  11.7 KB  |  359 lines

  1. /*
  2.  * tcl.h --
  3.  *
  4.  *    This header file describes the externally-visible facilities
  5.  *    of the Tcl interpreter.
  6.  *
  7.  * Copyright 1987-1991 Regents of the University of California
  8.  * Permission to use, copy, modify, and distribute this
  9.  * software and its documentation for any purpose and without
  10.  * fee is hereby granted, provided that the above copyright
  11.  * notice appear in all copies.  The University of California
  12.  * makes no representations about the suitability of this
  13.  * software for any purpose.  It is provided "as is" without
  14.  * express or implied warranty.
  15.  *
  16.  * $Header: /user6/ouster/tcl/RCS/tcl.h,v 1.79 92/01/04 15:00:41 ouster Exp $ SPRITE (Berkeley)
  17.  */
  18.  
  19. #ifndef _TCL
  20. #define _TCL
  21.  
  22. #ifdef THINK_C
  23. #define macintosh
  24. #endif
  25.  
  26. #define TCL_VERSION "6.2"
  27.  
  28. /*
  29.  * Definitions that allow this header file to be used either with or
  30.  * without ANSI C features like function prototypes.
  31.  */
  32.  
  33. #undef _ANSI_ARGS_
  34. #undef const
  35. #if (defined(THINK_C) || defined(__STDC__) || defined(__cplusplus) || defined(SABER)) && !defined(NO_PROTOTYPE)
  36. #   define _ANSI_ARGS_(x)    x
  37. #   define CONST const
  38. #   if (defined (__cplusplus) || defined(THINK_C))
  39. #       define VARARGS (...)
  40. #   else
  41. #       define VARARGS ()
  42. #   endif
  43. #else
  44. #   define _ANSI_ARGS_(x)    ()
  45. #   define CONST
  46. #endif
  47.  
  48. #ifdef __cplusplus
  49. #   define EXTERN extern "C"
  50. #else
  51. #   define EXTERN extern
  52. #endif
  53.  
  54. /*
  55.  * Miscellaneous declarations (to allow Tcl to be used stand-alone,
  56.  * without the rest of Sprite).
  57.  */
  58.  
  59. #ifndef NULL
  60. #define NULL 0
  61. #endif
  62.  
  63. #ifndef _CLIENTDATA
  64. typedef int *ClientData;
  65. #define _CLIENTDATA
  66. #endif
  67.  
  68. /*
  69.  * Data structures defined opaquely in this module.  The definitions
  70.  * below just provide dummy types.  A few fields are made visible in
  71.  * Tcl_Interp structures, namely those for returning string values.
  72.  * Note:  any change to the Tcl_Interp definition below must be mirrored
  73.  * in the "real" definition in tclInt.h.
  74.  */
  75.  
  76. typedef struct Tcl_Interp{
  77.     char *result;        /* Points to result string returned by last
  78.                  * command. */
  79.     void (*freeProc) _ANSI_ARGS_((char *blockPtr));
  80.                 /* Zero means result is statically allocated.
  81.                  * If non-zero, gives address of procedure
  82.                  * to invoke to free the result.  Must be
  83.                  * freed by Tcl_Eval before executing next
  84.                  * command. */
  85.     int errorLine;        /* When TCL_ERROR is returned, this gives
  86.                  * the line number within the command where
  87.                  * the error occurred (1 means first line). */
  88. } Tcl_Interp;
  89.  
  90. typedef int *Tcl_Trace;
  91. typedef int *Tcl_CmdBuf;
  92.  
  93. /*
  94.  * When a TCL command returns, the string pointer interp->result points to
  95.  * a string containing return information from the command.  In addition,
  96.  * the command procedure returns an integer value, which is one of the
  97.  * following:
  98.  *
  99.  * TCL_OK        Command completed normally;  interp->result contains
  100.  *            the command's result.
  101.  * TCL_ERROR        The command couldn't be completed successfully;
  102.  *            interp->result describes what went wrong.
  103.  * TCL_RETURN        The command requests that the current procedure
  104.  *            return;  interp->result contains the procedure's
  105.  *            return value.
  106.  * TCL_BREAK        The command requests that the innermost loop
  107.  *            be exited;  interp->result is meaningless.
  108.  * TCL_CONTINUE        Go on to the next iteration of the current loop;
  109.  *            interp->result is meaninless.
  110.  */
  111.  
  112. #define TCL_OK        0
  113. #define TCL_ERROR    1
  114. #define TCL_RETURN    2
  115. #define TCL_BREAK    3
  116. #define TCL_CONTINUE    4
  117.  
  118. #define TCL_RESULT_SIZE 199
  119.  
  120. /*
  121.  * Procedure types defined by Tcl:
  122.  */
  123.  
  124. typedef void (Tcl_CmdDeleteProc) _ANSI_ARGS_((ClientData clientData));
  125. typedef int (Tcl_CmdProc) _ANSI_ARGS_((ClientData clientData,
  126.     Tcl_Interp *interp, int argc, char *argv[]));
  127. typedef void (Tcl_CmdTraceProc) _ANSI_ARGS_((ClientData clientData,
  128.     Tcl_Interp *interp, int level, char *command, Tcl_CmdProc *proc,
  129.     ClientData cmdClientData, int argc, char *argv[]));
  130. typedef void (Tcl_FreeProc) _ANSI_ARGS_((char *blockPtr));
  131. typedef char *(Tcl_VarTraceProc) _ANSI_ARGS_((ClientData clientData,
  132.     Tcl_Interp *interp, char *name1, char *name2, int flags));
  133.  
  134. /*
  135.  * Flag values passed to Tcl_Eval (see the man page for details;  also
  136.  * see tclInt.h for additional flags that are only used internally by
  137.  * Tcl):
  138.  */
  139.  
  140. #define TCL_BRACKET_TERM    1
  141.  
  142. /*
  143.  * Flag that may be passed to Tcl_ConvertElement to force it not to
  144.  * output braces (careful!  if you change this flag be sure to change
  145.  * the definitions at the front of tclUtil.c).
  146.  */
  147.  
  148. #define TCL_DONT_USE_BRACES    1
  149.  
  150. /*
  151.  * Flag value passed to Tcl_RecordAndEval to request no evaluation
  152.  * (record only).
  153.  */
  154.  
  155. #define TCL_NO_EVAL        -1
  156.  
  157. /*
  158.  * Specil freeProc values that may be passed to Tcl_SetResult (see
  159.  * the man page for details):
  160.  */
  161.  
  162. #define TCL_VOLATILE    ((Tcl_FreeProc *) -1)
  163. #define TCL_STATIC    ((Tcl_FreeProc *) 0)
  164. #define TCL_DYNAMIC    ((Tcl_FreeProc *) free)
  165.  
  166. /*
  167.  * Flag values passed to variable-related procedures.
  168.  */
  169.  
  170. #define TCL_GLOBAL_ONLY        1
  171. #define TCL_APPEND_VALUE    2
  172. #define TCL_LIST_ELEMENT    4
  173. #define TCL_NO_SPACE        8
  174. #define TCL_TRACE_READS        0x10
  175. #define TCL_TRACE_WRITES    0x20
  176. #define TCL_TRACE_UNSETS    0x40
  177. #define TCL_TRACE_DESTROYED    0x80
  178. #define TCL_INTERP_DESTROYED    0x100
  179. #define TCL_LEAVE_ERR_MSG    0x200
  180.  
  181. /*
  182.  * Additional flag passed back to variable watchers.  This flag must
  183.  * not overlap any of the TCL_TRACE_* flags defined above or the
  184.  * TRACE_* flags defined in tclInt.h.
  185.  */
  186.  
  187. #define TCL_VARIABLE_UNDEFINED    8
  188.  
  189. /*
  190.  * The following declarations either map ckalloc and ckfree to
  191.  * malloc and free, or they map them to procedures with all sorts
  192.  * of debugging hooks defined in tclCkalloc.c.
  193.  */
  194.  
  195. #ifdef TCL_MEM_DEBUG
  196.  
  197. EXTERN char *        Tcl_DbCkalloc _ANSI_ARGS_((unsigned int size,
  198.                 char *file, int line));
  199. EXTERN int        Tcl_DbCkfree _ANSI_ARGS_((char *ptr,
  200.                 char *file, int line));
  201. #  define ckalloc(x) Tcl_DbCkalloc(x, __FILE__, __LINE__)
  202. #  define ckfree(x)  Tcl_DbCkfree(x, __FILE__, __LINE__)
  203.  
  204. #else
  205.  
  206. #  define ckalloc(x) malloc(x)
  207. #  define ckfree(x)  free(x)
  208.  
  209. #endif /* TCL_MEM_DEBUG */
  210.  
  211. /*
  212.  * Macro to free up result of interpreter.
  213.  */
  214.  
  215. #define Tcl_FreeResult(interp)                    \
  216.     if ((interp)->freeProc != 0) {                \
  217.     if ((interp)->freeProc == (Tcl_FreeProc *) free) {    \
  218.         ckfree((interp)->result);                \
  219.     } else {                        \
  220.         (*(interp)->freeProc)((interp)->result);        \
  221.     }                            \
  222.     (interp)->freeProc = 0;                    \
  223.     }
  224.  
  225. /*
  226.  * Exported Tcl procedures:
  227.  */
  228.  
  229. EXTERN void        Tcl_AppendElement _ANSI_ARGS_((Tcl_Interp *interp,
  230.                 char *string, int noSep));
  231. #ifdef macintosh
  232. EXTERN void        Tcl_AppendResult(Tcl_Interp *interp, ...);
  233. #else
  234. EXTERN void        Tcl_AppendResult _ANSI_ARGS_(VARARGS);
  235. #endif
  236. EXTERN char *        Tcl_AssembleCmd _ANSI_ARGS_((Tcl_CmdBuf buffer,
  237.                 char *string));
  238. EXTERN void        Tcl_AddErrorInfo _ANSI_ARGS_((Tcl_Interp *interp,
  239.                 char *message));
  240. EXTERN char        Tcl_Backslash _ANSI_ARGS_((char *src,
  241.                 int *readPtr));
  242. EXTERN char *        Tcl_Concat _ANSI_ARGS_((int argc, char **argv));
  243. EXTERN int        Tcl_ConvertElement _ANSI_ARGS_((char *src,
  244.                 char *dst, int flags));
  245. EXTERN Tcl_CmdBuf    Tcl_CreateCmdBuf _ANSI_ARGS_((void));
  246. EXTERN void        Tcl_CreateCommand _ANSI_ARGS_((Tcl_Interp *interp,
  247.                 char *cmdName, Tcl_CmdProc *proc,
  248.                 ClientData clientData,
  249.                 Tcl_CmdDeleteProc *deleteProc));
  250. EXTERN Tcl_Interp *    Tcl_CreateInterp _ANSI_ARGS_((void));
  251. EXTERN int        Tcl_CreatePipeline _ANSI_ARGS_((Tcl_Interp *interp,
  252.                 int argc, char **argv, int **pidArrayPtr,
  253.                 int *inPipePtr, int *outPipePtr,
  254.                 int *errFilePtr));
  255. EXTERN Tcl_Trace    Tcl_CreateTrace _ANSI_ARGS_((Tcl_Interp *interp,
  256.                 int level, Tcl_CmdTraceProc *proc,
  257.                 ClientData clientData));
  258. EXTERN void        Tcl_DeleteCmdBuf _ANSI_ARGS_((Tcl_CmdBuf buffer));
  259. EXTERN int        Tcl_DeleteCommand _ANSI_ARGS_((Tcl_Interp *interp,
  260.                 char *cmdName));
  261. EXTERN void        Tcl_DeleteInterp _ANSI_ARGS_((Tcl_Interp *interp));
  262. EXTERN void        Tcl_DeleteTrace _ANSI_ARGS_((Tcl_Interp *interp,
  263.                 Tcl_Trace trace));
  264. EXTERN void        Tcl_DetachPids _ANSI_ARGS_((int numPids, int *pidPtr));
  265. EXTERN char *        Tcl_ErrnoId _ANSI_ARGS_((void));
  266. EXTERN int        Tcl_Eval _ANSI_ARGS_((Tcl_Interp *interp, char *cmd,
  267.                 int flags, char **termPtr));
  268. EXTERN int        Tcl_EvalFile _ANSI_ARGS_((Tcl_Interp *interp,
  269.                 char *fileName));
  270. EXTERN int        Tcl_ExprBoolean _ANSI_ARGS_((Tcl_Interp *interp,
  271.                 char *string, int *ptr));
  272. EXTERN int        Tcl_ExprDouble _ANSI_ARGS_((Tcl_Interp *interp,
  273.                 char *string, double *ptr));
  274. EXTERN int        Tcl_ExprLong _ANSI_ARGS_((Tcl_Interp *interp,
  275.                 char *string, long *ptr));
  276. EXTERN int        Tcl_ExprString _ANSI_ARGS_((Tcl_Interp *interp,
  277.                 char *string));
  278. EXTERN int        Tcl_Fork _ANSI_ARGS_((void));
  279. EXTERN int        Tcl_GetBoolean _ANSI_ARGS_((Tcl_Interp *interp,
  280.                 char *string, int *boolPtr));
  281. EXTERN int        Tcl_GetDouble _ANSI_ARGS_((Tcl_Interp *interp,
  282.                 char *string, double *doublePtr));
  283. EXTERN int        Tcl_GetInt _ANSI_ARGS_((Tcl_Interp *interp,
  284.                 char *string, int *intPtr));
  285. EXTERN char *        Tcl_GetVar _ANSI_ARGS_((Tcl_Interp *interp,
  286.                 char *varName, int flags));
  287. EXTERN char *        Tcl_GetVar2 _ANSI_ARGS_((Tcl_Interp *interp,
  288.                 char *name1, char *name2, int flags));
  289. EXTERN void        Tcl_InitHistory _ANSI_ARGS_((Tcl_Interp *interp));
  290. EXTERN void        Tcl_InitMemory _ANSI_ARGS_((Tcl_Interp *interp));
  291. EXTERN char *        Tcl_Merge _ANSI_ARGS_((int argc, char **argv));
  292. EXTERN char *        Tcl_ParseVar _ANSI_ARGS_((Tcl_Interp *interp,
  293.                 char *string, char **termPtr));
  294. EXTERN int        Tcl_RecordAndEval _ANSI_ARGS_((Tcl_Interp *interp,
  295.                 char *cmd, int flags));
  296. EXTERN void        Tcl_ResetResult _ANSI_ARGS_((Tcl_Interp *interp));
  297. #define Tcl_Return Tcl_SetResult
  298. EXTERN int        Tcl_ScanElement _ANSI_ARGS_((char *string,
  299.                 int *flagPtr));
  300. #ifdef macintosh
  301. EXTERN void        Tcl_SetErrorCode(Tcl_Interp *interp, ...);
  302. #else
  303. EXTERN void        Tcl_SetErrorCode _ANSI_ARGS_(VARARGS);
  304. #endif
  305. EXTERN void        Tcl_SetResult _ANSI_ARGS_((Tcl_Interp *interp,
  306.                 char *string, Tcl_FreeProc *freeProc));
  307. EXTERN char *        Tcl_SetVar _ANSI_ARGS_((Tcl_Interp *interp,
  308.                 char *varName, char *newValue, int flags));
  309. EXTERN char *        Tcl_SetVar2 _ANSI_ARGS_((Tcl_Interp *interp,
  310.                 char *name1, char *name2, char *newValue,
  311.                 int flags));
  312. EXTERN char *        Tcl_SignalId _ANSI_ARGS_((int sig));
  313. EXTERN char *        Tcl_SignalMsg _ANSI_ARGS_((int sig));
  314. EXTERN int        Tcl_SplitList _ANSI_ARGS_((Tcl_Interp *interp,
  315.                 char *list, int *argcPtr, char ***argvPtr));
  316. EXTERN int        Tcl_StringMatch _ANSI_ARGS_((char *string,
  317.                 char *pattern));
  318. EXTERN char *        Tcl_TildeSubst _ANSI_ARGS_((Tcl_Interp *interp,
  319.                 char *name));
  320. EXTERN int        Tcl_TraceVar _ANSI_ARGS_((Tcl_Interp *interp,
  321.                 char *varName, int flags, Tcl_VarTraceProc *proc,
  322.                 ClientData clientData));
  323. EXTERN int        Tcl_TraceVar2 _ANSI_ARGS_((Tcl_Interp *interp,
  324.                 char *name1, char *name2, int flags,
  325.                 Tcl_VarTraceProc *proc, ClientData clientData));
  326. EXTERN char *        Tcl_UnixError _ANSI_ARGS_((Tcl_Interp *interp));
  327. EXTERN int        Tcl_UnsetVar _ANSI_ARGS_((Tcl_Interp *interp,
  328.                 char *varName, int flags));
  329. EXTERN int        Tcl_UnsetVar2 _ANSI_ARGS_((Tcl_Interp *interp,
  330.                 char *name1, char *name2, int flags));
  331. EXTERN void        Tcl_UntraceVar _ANSI_ARGS_((Tcl_Interp *interp,
  332.                 char *varName, int flags, Tcl_VarTraceProc *proc,
  333.                 ClientData clientData));
  334. EXTERN void        Tcl_UntraceVar2 _ANSI_ARGS_((Tcl_Interp *interp,
  335.                 char *name1, char *name2, int flags,
  336.                 Tcl_VarTraceProc *proc, ClientData clientData));
  337. #ifdef macintosh
  338. EXTERN int        Tcl_VarEval(Tcl_Interp *interp,...);
  339. #else
  340. EXTERN int        Tcl_VarEval _ANSI_ARGS_(VARARGS);
  341. #endif
  342. EXTERN ClientData    Tcl_VarTraceInfo _ANSI_ARGS_((Tcl_Interp *interp,
  343.                 char *varName, int flags,
  344.                 Tcl_VarTraceProc *procPtr,
  345.                 ClientData prevClientData));
  346. EXTERN ClientData    Tcl_VarTraceInfo2 _ANSI_ARGS_((Tcl_Interp *interp,
  347.                 char *name1, char *name2, int flags,
  348.                 Tcl_VarTraceProc *procPtr,
  349.                 ClientData prevClientData));
  350. EXTERN int        Tcl_WaitPids _ANSI_ARGS_((int numPids, int *pidPtr,
  351.                 int *statusPtr));
  352.  
  353. #endif /* _TCL */
  354.  
  355. #include "icemalloc.h"
  356. #define malloc icemalloc
  357. #define free icefree
  358.  
  359.